import type { IFormItem } from '@/components/NFormBuilder/types'
import type { CreateFormItemsOptions } from '@/types/fcform'
import { ScConstants } from '@/components/NFormBuilder/unit/ScConstants'
export const createFormItems = (options: CreateFormItemsOptions): IFormItem[] => {
  const { optionsState, formData } = options
  const sc = new ScConstants(24)
  return [
    sc.select('类型', 'dictType', {
      labelField: 'description',
      valueField: 'dictType',
      options: optionsState.treeList,
      onUpdateValue: (_: string, item: Record<string, unknown>) => {
        if (item) formData.value.dictId = item.id as string
        else formData.value.dictId = null
      },
    }),
    sc.input('标签名', 'label'),
    sc.input('数据值', 'itemValue'),
    sc.input('描述', 'description'),
    sc.number('排序', 'sortOrder'),
    sc.input('备注', 'remarks'),
  ]
}
